package com.bottle.web;

import com.bottle.enity.User;
import com.bottle.mode.ReJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: chenyuncong
 * @Date: 2020/5/11 18:16
 * 用来做测试数据接口
 */
@RestController
@RequestMapping("test")
public class TestController {
    @Autowired
    private MongoTemplate mongoTemplate;

    //获取账号
    @GetMapping("getUserByAccount")
    public ReJson<User> getUserByAccount(String account){
        Query query=new Query(Criteria.where("account").is(account)).limit(1);
        User user = mongoTemplate.findOne(query,User.class);
        return new ReJson<>(user);
    }


}
